﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Data.SqlClient;
using System.Data;
using ClassLibraryDatabase;

namespace ClassLibraryBaseClass
{
	/// <summary>
	///Register 的摘要说明
	/// </summary>
	public class Register
	{
		public Register()
		{
			//
			//TODO: 在此处添加构造函数逻辑
			//
		}
		public static void AddUserInformation(string sMail, string sName, string sPassword, string sCheckPassword, string CheckWord)
		{
			if (sPassword == sCheckPassword && !sName.Contains("@"))
			{
				//插入新用户
				UserModify.AddUser(sName, null, DateTime.Now, DateTime.Now, "M", sMail, null, sPassword);

				//生成密码
				MD5 md5 = new MD5CryptoServiceProvider();
				byte[] data = System.Text.Encoding.Default.GetBytes(sPassword);//将字符编码为一个字节序列 
				byte[] md5_password = md5.ComputeHash(data);//计算data字节数组的哈希值

				//插入新用户的密码
				string[] value = { sName, md5.ToString() };
				string tablename = "PassWord";
				DataBaseClass.insertData(value, tablename, DataBaseClass.GetConnectionString());
			}

		}
	}
}